package cn.wolfcode.crm.query;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.util.StringUtils;

@Getter
@Setter
public class QueryObject {
    private Integer rows = 10;
    private Integer page = 1;
    // 排序的 列
    private String sort;
    // 排序规则
    private String order;
    public int getStart() {
        return (page - 1) * rows;
    }

    public String getSort() {
        if (sort == null) {
            return null;
        }
        if ("dept".equals(sort)) {
            return "e.dept_id";
        }
        return "e." + sort;
    }

    //判断是否有长度,如果没有长度则返回null
    protected String empty2Null(String str){
        return StringUtils.hasLength(str) ? str : null;
    }
}
